var isMSIE = /* @cc_on!@ */0;
if (isMSIE) {
  document.body.style.marginLeft = (document.body.clientWidth - 1000) / 2
      + "px";
}

$(document).ready(initPage);


function initPage() {
  
  $('#buttonNavBar').click(function() {
    
    if ($('.nav-collapse').height() == 0) {
      $('.nav-collapse').height('auto');
    } else {
      $('.nav-collapse').height(0)
    }
  })
  setFooterHeight();
  setTimeout(setFooterHeight, 3000);
  initMenuClick();
  initAndroidClass();
}



$(window).resize(function() {
  setFooterHeight();
})

/**
 * Beautiful footer : When the content is too hsort, the footer will continue 
 * until the bottom of the page.
 */
function setFooterHeight() {
  $('#footer').height('auto');
  if ($('#footer').offset() && typeof($('#footer').offset().top) != 'undefined' &&
      $('#footer').offset().top + $('#footer').height() < $(window).height()) {
    $('#footer').height($(window).height() - $('#footer').offset().top); 
  }
}

/**
 * Initializes the menu.
 */
function initMenuClick() {
  $('.nav> li').click(function() {
    if (document.documentElement.clientWidth > 1000) return;
      if (!$(this).is(':visible')) {
        $(this).find('ul').css('display', 'none');
      }
      $(this).find('ul').slideToggle();
  })
}

function la(action, page, content) {
  $.ajax('ajax/logAction.php?action=' + action + '&page=' + page + '&content=' + content);
}

function laCurrentUrl(action, content) {
  $.ajax('ajax/logAction.php?action=' + action + '&page=' + window.location.href.replace('http://' + window.location.host, '') + '&content=' + content);
}


function displayMoreTable() {
  $('#moreTable').slideToggle();
  $('.moreTableButtonWrapper').hide();
  laCurrentUrl('displayMoreTable', '');
}

/**
 * 
 */
function initAndroidClass() {
  var ua = navigator.userAgent.toLowerCase();
  var isAndroid = ua.indexOf("android") > -1;
  if (isAndroid) {
	  $("html").addClass("isAndroid");
  }
}
